from typing import Callable

from fastapi import Request, Response
from fastapi.routing import APIRoute


class GetSessionRoute(APIRoute):
    """
    指定路由的类, 相当于路由的中间件
    """
    def get_route_handler(self) -> Callable:
        original_route_handler = super().get_route_handler()

        async def custom_route_handler(request: Request) -> Response:

            response: Response = await original_route_handler(request)
            return response

        return custom_route_handler